// JavaScript Document
$(function(){
   $('.Contact .box .form li .right .select').click(function(){
	   $(this).next('.option').slideToggle();
   });
   $('label').change(function(){
	   var cont = '';
	   var length = $(this).parent('.option').children('label');
	   for(var i=0;i<length.length;i++){
		   if($(length[i]).children().attr('checked') == true){
			   cont = $(length[i]).children('span').html() + '/' + cont;
		   } 
	   }
	   cont = cont.substring(0,cont.length-1);
	   $(this).parent('.option').prev('.select').children('.text').html(cont);
	   /*
	   var text = $(this).children('span').html();
	   var value = $('.select .text').html();
	   $(this).parent('.option').prev('.select').children('.text').html(value+'/'+text);
	   */
   });
   var isSub = true;

   count = function () {
      var tempHeight=$("#height").val() / 100;
      var temp = tempHeight * tempHeight;
      temp = ($("#weight").val() / temp).toFixed(1);
      $("#bmi").val(temp);
      isSub = false;
   };

   $("#height").blur(function () {
      if($("#weight").val() == ""){
         return;
      }
      else{
         return count();
      }
   });

   $("#weight").blur(function () {
      if($("#height").val() == ""){
         return;
      }
      else{
         return count();
      }
   });

   $("#sub_btn").click(function () {
   	if($("#name").val() == ""){
   		alert("姓名不能为空");
   		return;
   	}
   	if($("#phone").val() == ""){
   		alert("电话不能为空");
   		return;
   	}
   	if(!(/^1[3458]\d{9}$/.test($("#phone").val()))){
   		alert("请输入正确的电话号码");
   		return;
   	}
      if(isSub){
         return;
      }
   	$("#myform").submit();
   });
});